package com.mxx.common.utils;

import com.alibaba.fastjson.JSONObject;
import com.mxx.common.conv.JsonUtil;
import com.mxx.common.http.ApacheHttpResponse;
import com.mxx.common.http.ApacheHttpUtil;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.util.Collections;

/**
 * @Author itzgyw
 * @Date 2020-04-01
 * @Time 15:25
 * @Description: 获取地址信息
 */
@Slf4j
public class MobileForm {

    public static String getRealProvinceForTaoBao(String phone) throws IOException {
        String url = "https://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=" + phone;
        ApacheHttpResponse responseEntity = ApacheHttpUtil.doGet(url, Collections.EMPTY_MAP);
        String resultStr = responseEntity.getBody();
        resultStr = resultStr.replace("__GetZoneResult_ =", "").trim();
        JSONObject entity = JsonUtil.toJSON(resultStr);
        return entity.getString("province");
    }


}
